//
//  YDYNewFeatureCollectionViewCell.m
//  DY_Weibo3
//
//  Created by 杨德勇 on 2016/8/21.
//  Copyright © 2016年 杨德勇. All rights reserved.
//

#import "YDYNewFeatureCollectionViewCell.h"
@interface YDYNewFeatureCollectionViewCell()
/*背景图片*/
@property (weak, nonatomic) IBOutlet UIImageView *backImgView;
@property (weak, nonatomic) IBOutlet UIButton *startBtn;


@end

@implementation YDYNewFeatureCollectionViewCell
-(void)awakeFromNib{
    [super awakeFromNib];
    [self setupUI];
    
}

-(void)setupUI{
    
    //nib生成后，系统自动添加一个view在所有子控件上面，导致按钮失效
    [self bringSubviewToFront:self.startBtn];
    self.startBtn.hidden = YES;
}

-(void)startAnimation{
    self.startBtn.hidden = NO;
    
    self.startBtn.transform = CGAffineTransformMakeScale(0.0001, 0.0001);
    [UIView animateWithDuration:2.0 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:20 options:0 animations:^{
        self.startBtn.transform = CGAffineTransformIdentity;
    } completion:^(BOOL finished) {
        self.startBtn.enabled = YES;
        self.startBtn.userInteractionEnabled = YES;
    }];
}

    
#pragma mark -
#pragma mark -懒加载
-(void)setImgIndex:(NSInteger)imgIndex{
    _imgIndex = imgIndex;
    self.backImgView.image = [UIImage imageNamed:[NSString stringWithFormat:@"new_feature_%ld",self.imgIndex + 1]];
    
}

- (IBAction)startBtnDidClick:(id)sender {
    //跳转到主页面
    [[NSNotificationCenter defaultCenter]postNotificationName:YDYChangeRootViewControllerNotification object:self];
//    [UIApplication sharedApplication].keyWindow.rootViewController = [UIStoryboard storyboardWithName:@"Main" bundle:nil].instantiateInitialViewController;
}


@end
